package com.dream.service.basic;


import com.dream.common.utils.SpringContextUtil;
import com.dream.mapper.*;
import com.dream.service.DelayRelayQueue;
import com.dream.service.ProcedureServiceImpl;
import com.dream.net.socket.base.SocketController;
import com.dream.web.websocket.ConsoleWebSocket;

/**
 * 避免从SpringContext重复获取
 * 提高效率，虽然上下文效率也很高
 */
public class BaseServiceHelper {
    private static FriendManagerMapper friendManagerMapper = null;
    private static GroupInfoMapper groupInfoMapper;
    private static GroupMemberMapper groupMemberMapper;
    private static ConsoleWebSocket consoleWebSocket;
    private static ProcedureServiceImpl procedureService;
    private static RedisCacheService redisCacheService;
    private static UserFieldMapper userFieldMapper;
    private static AsyncInvokeService asyncInvokeService;
    private static RedPackageSendMapper redPackageSendMapper;
    private static RedPackagePickMapper redPackagePickMapper;
    private static SocketController socketController;
    private static DelayRelayQueue delayRelayQueue;

    public static FriendManagerMapper getFriendManagerMapper() {
        return friendManagerMapper == null ? friendManagerMapper = SpringContextUtil.getBean(FriendManagerMapper.class) : friendManagerMapper;
    }

    public static GroupInfoMapper getGroupInfoMapper() {
        return groupInfoMapper == null ? groupInfoMapper = SpringContextUtil.getBean(GroupInfoMapper.class) : groupInfoMapper;
    }

    public static GroupMemberMapper getGroupMemberMapper() {
        return groupMemberMapper == null ? groupMemberMapper = SpringContextUtil.getBean(GroupMemberMapper.class) : groupMemberMapper;
    }

    public static ConsoleWebSocket getConsoleWebSocket() {
        return consoleWebSocket == null ? consoleWebSocket = SpringContextUtil.getBean(ConsoleWebSocket.class) : consoleWebSocket;
    }

    public static ProcedureServiceImpl getProcedureServiceImpl() {
        return procedureService == null ? procedureService = SpringContextUtil.getBean(ProcedureServiceImpl.class) : procedureService;
    }

    public static RedisCacheService getRedisCacheService() {
        return redisCacheService == null ? redisCacheService = SpringContextUtil.getBean(RedisCacheService.class) : redisCacheService;
    }

    public static UserFieldMapper getUserFieldMapper() {
        return userFieldMapper == null ? userFieldMapper = SpringContextUtil.getBean(UserFieldMapper.class) : userFieldMapper;
    }

    public static AsyncInvokeService getAsyncInvokeService() {
        return asyncInvokeService == null ? asyncInvokeService = SpringContextUtil.getBean(AsyncInvokeService.class) : asyncInvokeService;
    }

    public static RedPackageSendMapper getRedPackageSendMapper() {
        return redPackageSendMapper == null ? redPackageSendMapper = SpringContextUtil.getBean(RedPackageSendMapper.class) : redPackageSendMapper;
    }

    public static RedPackagePickMapper getRedPackagePickMapper() {
        return redPackagePickMapper == null ? redPackagePickMapper = SpringContextUtil.getBean(RedPackagePickMapper.class) : redPackagePickMapper;
    }

    public static SocketController getSocketController() {
        return socketController == null ? socketController = SpringContextUtil.getBean(SocketController.class) : socketController;
    }

    public static DelayRelayQueue getDelayRelayQueue() {
        return delayRelayQueue == null ? delayRelayQueue = SpringContextUtil.getBean(DelayRelayQueue.class) : delayRelayQueue;
    }
}
